home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 50
/
Amiga Format AFCD50 (Issue 134, March 2000).iso
/
+system+
/
afcdfind-handlematch.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-04
|
6KB
|
186 lines
/* $VER: AFCDFind-HandleMatch.rexx 2.0 (3.11.99)
**
** Support script used by AFCDFind search results
**
** Usage: AFCDFind-HandleMatch.rexx <pathname>
** Looks in ENV:AFCDFind_DOpus for config options
**
** Author: Oliver Roberts
** E-Mail: oliver.roberts@iname.com
** WWW: http://www.nanunanu.org/~oliver/
*/
options results
options failat 21
address REXX
/* Parse in arguments */
parse arg pathname
/* OS 3.5 or DOpus running? */
if ~Show("P","WORKBENCH") then do
if ~Show("P","DOPUS.1") then EXIT
else do
usedopus = 1
/* WBR mode? */
address "DOPUS.1" dopus screen
screen = RESULT
if (word(screen,1) = 'Workbench') then wbr = 1
else wbr = 0
end
end
else usedopus = 0
/* Check for required lib */
if ~show('l', 'rexxsupport.library') then do
call addlib('rexxsupport.library', 0, -30, 0)
if ~show('l', 'rexxsupport.library') then do
if (usedopus = 1) then do
address "DOPUS.1" dopus request '"This feature requires LIBS:rexxsupport.library" OK'
end
else do
address command 'C:RequestChoice AFCDFind "This feature requires LIBS:rexxsupport.library" OK'
end
EXIT
end
end
/* Check DOpus version and exit if older than v5.5 */
if (usedopus = 1) then do
address "DOPUS.1"
dopus version
if ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
dopus request '"This feature requires DOpus v5.5 or greater." OK'
EXIT
end
end
/* Parse in options in environment variable */
CALL GetEnv('AFCDFind_ViewOpts')
config = RESULT
parse var config . listermode
/* Turn AmigaDOS 'Insert Volume' requesters off */
pragma('W','N')
/* Determine if the correct CD is inserted, and if not, ask the user to
insert it */
volume = left(pathname,pos(':',pathname))
DO UNTIL (correctcd = 0 | exists(volume))
correctcd = 1;
if (~exists(volume)) then do
msg = "Please insert Amiga Format CD " || substr(volume,5,length(volume)-5)
if (usedopus = 1) then do
if (wbr = 0) then address "DOPUS.1" dopus front
address "DOPUS.1" dopus request '"'msg'" OK|Cancel'
correctcd = RC
end
else do
address command 'C:RequestChoice >T:HandleMatch.tmp AFCDFind "'msg'" "OK|Cancel"'
if OPEN(TMP,'T:HandleMatch.tmp',R) then do
correctcd = word(readln(TMP),1)
call close TMP
delete('T:HandleMatch.tmp')
end
else corrected = 0
end
end
end
/* Do the action if requested CD is available */
if (correctcd = 1 & exists(volume)) then do
stat = statef(pathname)
if (WORD(stat,1) = 'DIR') then do
/* Drawer button: Open the lister */
/* If drawer has no icon, make sure we are in showall mode */
drawericon = pathname
if (right(drawericon,1) = '/') then drawericon = left(drawericon,length(drawericon)-1)
drawericon = drawericon || '.info'
hasicon = 1
if (~exists(drawericon)) then do
if (find(listermode,'showall') == 0) then listermode = listermode 'showall'
hasicon = 0
end
if (usedopus = 1) then do
/******************************************************************
********************** Directory Opus Mode ************************
******************************************************************/
address "DOPUS.1"
if (wbr = 0) then dopus front
dopus version
if (translate(result,'.',' ') < 5.8) then do
/* Open the lister the messy way - workaround for bug in DOpus */
lister new pathname
ourlister = RESULT
if (word(listermode,1) ~= 'name') then do
if (pos('showall',listermode) = 0 | pos('default',listermode) ~= 0) then do
lister set ourlister mode listermode
end
end
end
else do
/* Open the lister the clean way with DOpus 5.8 or higher */
if (hasicon == 1 & word(listermode,1) ~= 'name') then do
if (word(listermode,1) ~= 'default') then do
lister new mode listermode fromicon pathname
end
else do
lister new fromicon pathname
end
end
else do
if (word(listermode,1) ~= 'default') then do
lister new mode listermode pathname
end
else do
lister new pathname
end
end
end
end
else do
/******************************************************************
********************** Workbench Mode (OS 3.5) ********************
******************************************************************/
address WORKBENCH
'WINDOW "'pathname'" OPEN'
if (word(listermode,1) ~= 'default') then do
if (word(listermode,1) = 'name') then 'MENU WINDOW "'pathname'" INVOKE WINDOW.VIEWBY.NAME'
if (word(listermode,1) = 'icon') then 'MENU WINDOW "'pathname'" INVOKE WINDOW.VIEWBY.ICON'
if (POS('showall',listermode) ~= 0) then 'MENU WINDOW "'pathname'" INVOKE WINDOW.SHOW.ALLFILES'
else 'MENU WINDOW "'pathname'" INVOKE WINDOW.SHOW.ONLYICONS'
end
end
end
else do
/* File button: get DOpus to act on file according to filetypes */
if (usedopus = 1) then address "DOPUS.1" command doubleclick pathname
end
end
/* Finished */
EXIT
/* Procedure definitions */
/* GetEnv() return the value of an environmental variable */
GetEnv: procedure
/* Arguments: **
** arg(1) := The name of the variable to retrieve **
** Returns a string */
/* Use function from rexxarplib if it's available */
if show('L', 'rexxarplib.library') then
return 'GetEnv'(arg(1))
/* OPEN() will fail if variable is not defined. Null will be **
** returned in that case */
if open(6Env, 'env:'arg(1), 'R') then do
EnvVar = readln(6Env)
call close 6Env
end
else EnvVar = ''
return EnvVar